package com.lx.mobileplayer.mvp.view.fragment

import android.view.View
import com.lx.mobileplayer.mvp.model.HomeItemBean
import com.lx.mobileplayer.mvp.persenter.HomePresenter
import com.lx.mobileplayer.mvp.view.Iview.IHomeView
import com.lx.mobileplayer.mvp.view.adapter.BaseAdater
import com.lx.mobileplayer.mvp.view.adapter.HomeAdapter
import com.lx.mobileplayer.utils.ToastUtil

/**
 * 类说明：首页
 * Created by liuxiong on 2019/4/24.
 */
class HomeFragment :BaseListFragment<HomeAdapter,HomeItemBean>(),IHomeView{

    private val mPresenter by lazy{
        HomePresenter(this)
    }

    override fun initView() {
        super.initView()

        mAdapter.setOnItemClickListener(object :BaseAdater.OnItemClickListener{
            override fun onItemClick(itemView: View, position: Int) {

                ToastUtil.show(mAdapter.data.get(position).title)
            }
        })
    }

    override fun createAdapter(): HomeAdapter{
        return HomeAdapter()
    }

//    @Permission(permissions = [Manifest.permission.WRITE_EXTERNAL_STORAGE],
//        rationales = [Permissions.WRITE_EXTERNAL_STORAGE],
//        rejects = [Permissions.WRITE_EXTERNAL_STORAGE])
    override fun loadData(offset: Int, pageSize: Int) {
        mPresenter.requestData(offset,pageSize)
    }
}